package com.guojian.common.map;

import com.google.common.collect.Maps;

import java.util.LinkedHashMap;
import java.util.Map;

public class TableMap<R, K, V> extends LinkedHashMap<R, Map<K, V>> {

	private static final long serialVersionUID = 3801626559108680964L;
	
	/*
	 * public void put(R row, K key, V value) { List<Map<K, V>> rowList =
	 * get(row);
	 * 
	 * if (rowList == null) { rowList = Lists.newArrayList(); put(row, rowList);
	 * } Map<K, V> kvMap = Maps.newLinkedHashMap(); kvMap.put(key, value);
	 * rowList.add(kvMap); }
	 */

	public TableMap<R, K, V> put(R row, K key, V value) {
		Map<K, V> kvMap = super.get(row);
		if (kvMap == null) {
			kvMap = Maps.newLinkedHashMap();
			super.put(row, kvMap);
		}
		kvMap.put(key, value);
		return this;
	}

}
